<template>
  <a-card>
    <div class="ant-card-head-wrapper">
      <div class="ant-card-head-title">
        <span class="title">保健-体温</span>
        <span class="subtitle">数据时间：{{dataDate}}</span>
      </div>
      <div class="ant-card-extra">
        <a-button type="primary" @click="handleType('temp')">查看详情<a-icon type="caret-right" /></a-button>
      </div>
    </div>
    <div class="card-content">
      <!-- table区域-begin -->
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true, y: 180}"
        bordered
        rowKey="id"
        :columns="temp.columns"
        :dataSource="temp.dataSource"
        :pagination="false"
        :loading="temp.loading"
        class="j-table-force-nowrap">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>

        <span slot="temperature" slot-scope="text, record">
          <span :style="{ color: record.isNormal ? '#f00' : '' }">{{ text }}</span>
        </span>

        <span slot="action" slot-scope="text, record">
          <a-space>
            <!-- <a @click="handleDetail(record)">查看</a> -->
            <a @click="handleEdit(record)">编辑</a>
            <!-- <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a>删除</a>
            </a-popconfirm> -->
          </a-space>
        </span>
      </a-table>
    </div>
    <sk-temperature-record-modal ref="modalForm" @ok="modalFormOk"></sk-temperature-record-modal>
  </a-card>
</template>
<script>
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import SkTemperatureRecordModal from '../../health/modules/SkTemperatureRecordModal'
import { getAction } from '@/api/manage';

export default {
  name: 'temp',
  mixins:[JeecgListMixin, mixinDevice],
  components: {
    SkTemperatureRecordModal
  },
  props:[],
  data() {
    return {
      url: {
        templist: "health/skTemperatureRecord/getStudentDayTemperature",
        delete: "/health/skTemperatureRecord/delete",
      },
      studentId: '',
      dataDate: '',
      nextDate: '',
      pageSize: 5,
      temp: {
        loading: false,
        dataSource: [],
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:50,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'测量时间',
            align:"center",
            width:200,
            dataIndex: 'examinationTime'
          },
          {
            title:'体温(℃)',
            align:"center",
            // width:80,
            dataIndex: 'temperature',
            scopedSlots: { customRender: 'temperature' }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            width:200,
            scopedSlots: { customRender: 'action' }
          }
        ],
      },
    }
  },
  filters: {},
  
  computed: {},
  
  created() {
    this.dataDate = this.$skCommon.getDate(0)
    this.nextDate = this.$skCommon.getDate(0)
  },
  
  activated() {
  },

  mounted() {
    // this.load();
  },

  methods: {
    load(dataForm) {
      this.dataDate =  dataForm.dataDate
      this.nextDate =  dataForm.dataDate
      this.studentId = dataForm.studentId
      this.loadData();
    },
    loadData() {
      let params = {
        studentId: this.studentId,
        queryDate: this.dataDate,
      }
      this.temp.loading = true
      getAction(this.url.templist, params).then(res => {
        this.temp.loading = false
        if(res.success) {
          this.temp.dataSource = res.result
        }else {
          this.$message.warning(res.message);
        }
      }).catch(()=>{
        this.temp.loading = false
      })
    },
    handleType(type){
      this.$emit('detail', type)
    },
  }
}
</script>
<style scoped lang="less">

</style>